package com.hexorld.layer;

import java.util.ArrayList;

import com.hexorld.core.HVisualObject;


import android.content.Context;
import android.graphics.Canvas;

public abstract class Layer {
	protected ArrayList<HVisualObject> mChild = null;
	protected Layer mParent = null;
	protected int mWidth, mHeight;
	public int Z = 0;
	protected Context mContext = null;
	
	public Layer(Context context, int width, int height, int id){
		mContext = context;
		mWidth = width;
		mHeight = height;
		Z = id;
		mChild = new ArrayList<HVisualObject>();
	}
	
	public void add(HVisualObject vl){
		if(mChild != null && vl != null)
		{
			mChild.add(vl);
		}
	}
	
	public void remove(HVisualObject vl){
		if(mChild != null && mChild.indexOf(vl) != -1)
			mChild.remove(vl);
	}
	
	public void clearChildLayers(){
		if(mChild != null)
			mChild.clear();
	}
	
	
	public void setParent(Layer vl){
		mParent = vl;
	}
	
	public Layer getParent(){
		return mParent;
	}

	public void draw(Context context, Canvas canvas){
		for(HVisualObject obj : mChild)
			obj.draw(canvas);
	}
}
